<div class="container">
    <h1 id="pkg-overview">package jpeg</h1>
    <p><code>import "image/jpeg"</code>
    </p><p>jpeg包实现了jpeg格式图像的编解码。JPEG格式参见<a href="http://www.w3.org/Graphics/JPEG/itu-t81.pdf">http://www.w3.org/Graphics/JPEG/itu-t81.pdf</a></p>
    
    
		
        
        
        
        
        
        
        
        
        
        
    
    <h2 id="pkg-constants">Constants </h2>
    <pre>const <span id="DefaultQuality">DefaultQuality</span> = 75</pre>
    <p>DefaultQuality是默认的编码质量参数。</p>
    <h2 id="Reader">type <a href="https://github.com/golang/go/blob/master/src/image/jpeg/reader.go?name=release#88" title="View Source">Reader</a> </h2>
    <pre>type Reader interface {
    <a href="io.htm">io</a>.<a href="io.htm#Reader">Reader</a>
    <span id="Reader.ReadByte">ReadByte</span>() (c <a href="builtin.htm#byte">byte</a>, err <a href="builtin.htm#error">error</a>)
}</pre>
    <p>如果提供的io.Reader接口没有ReadByte方法，Decode函数会为该接口附加一个缓冲。</p>
    <h2 id="FormatError">type <a href="https://github.com/golang/go/blob/master/src/image/jpeg/reader.go?name=release#21" title="View Source">FormatError</a> </h2>
    <pre>type FormatError <a href="builtin.htm#string">string</a></pre>
    <p>当输入流不是合法的jpeg格式图像时，就会返回FormatError类型的错误。</p>
    <h3 id="FormatError.Error">func (FormatError) <a href="https://github.com/golang/go/blob/master/src/image/jpeg/reader.go?name=release#23" title="View Source">Error</a> </h3>
    <pre class="funcdecl">func (e <a href="#FormatError">FormatError</a>) Error() <a href="builtin.htm#string">string</a></pre>
    <h2 id="UnsupportedError">type <a href="https://github.com/golang/go/blob/master/src/image/jpeg/reader.go?name=release#26" title="View Source">UnsupportedError</a> </h2>
    <pre>type UnsupportedError <a href="builtin.htm#string">string</a></pre>
    <p>当输入流使用了合法但尚不支持的jpeg特性的时候，就会返回UnsupportedError类型的错误。</p>
    <h3 id="UnsupportedError.Error">func (UnsupportedError) <a href="https://github.com/golang/go/blob/master/src/image/jpeg/reader.go?name=release#28" title="View Source">Error</a> </h3>
    <pre class="funcdecl">func (e <a href="#UnsupportedError">UnsupportedError</a>) Error() <a href="builtin.htm#string">string</a></pre>
    <h2 id="Options">type <a href="https://github.com/golang/go/blob/master/src/image/jpeg/writer.go?name=release#488" title="View Source">Options</a> </h2>
    <pre>type Options struct {
    <span id="Options.Quality">Quality</span> <a href="builtin.htm#int">int</a>
}</pre>
    <p>Options是编码质量参数。取值范围[1,100]，越大图像编码质量越高。</p>
    <h2 id="Decode">func <a href="https://github.com/golang/go/blob/master/src/image/jpeg/reader.go?name=release#346" title="View Source">Decode</a> </h2>
    <pre class="funcdecl">func Decode(r <a href="io.htm">io</a>.<a href="io.htm#Reader">Reader</a>) (<a href="image.htm">image</a>.<a href="image.htm#Image">Image</a>, <a href="builtin.htm#error">error</a>)</pre>
    <p>从r读取一幅jpeg格式的图像并解码返回该图像。</p>
    <h2 id="DecodeConfig">func <a href="https://github.com/golang/go/blob/master/src/image/jpeg/reader.go?name=release#353" title="View Source">DecodeConfig</a> </h2>
    <pre class="funcdecl">func DecodeConfig(r <a href="io.htm">io</a>.<a href="io.htm#Reader">Reader</a>) (<a href="image.htm">image</a>.<a href="image.htm#Config">Config</a>, <a href="builtin.htm#error">error</a>)</pre>
    <p>返回JPEG图像的色彩模型和尺寸；函数不会解码整个图像。</p>
    <h2 id="Encode">func <a href="https://github.com/golang/go/blob/master/src/image/jpeg/writer.go?name=release#494" title="View Source">Encode</a> </h2>
    <pre class="funcdecl">func Encode(w <a href="io.htm">io</a>.<a href="io.htm#Writer">Writer</a>, m <a href="image.htm">image</a>.<a href="image.htm#Image">Image</a>, o *<a href="#Options">Options</a>) <a href="builtin.htm#error">error</a></pre>
    <p>Encode函数将采用JPEG 4:2:0基线格式和指定的编码质量将图像写入w。如果o为nil将使用DefaultQuality。</p>
</div>